package com.service.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.common.utils.PageUtils;
import com.common.utils.Query;
import com.dao.PaperManageDao;
import com.entity.PaperManageEntity;
import com.service.PaperManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("paperManageService")
public class PaperManageServiceImpl extends ServiceImpl<PaperManageDao, PaperManageEntity> implements PaperManageService {

    @Autowired
    private PaperManageDao paperManageDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<PaperManageEntity> page = this.page(
                new Query<PaperManageEntity>().getPage(params),
                new QueryWrapper<PaperManageEntity>()
                        .or().like("paperid",params.get("key"))
                        .or().like("questiontype",params.get("key"))
                        .or().like("questionid",params.get("key"))
        );

        return new PageUtils(page);
    }

    @Override
    public List<PaperManageEntity> getPaperList() {
        return paperManageDao.selectList(new QueryWrapper<PaperManageEntity>());
    }

    @Override
    public void removeByPaperId(Integer paperid) {
        paperManageDao.delete(new QueryWrapper<PaperManageEntity>().lambda().eq(PaperManageEntity::getPaperid,paperid));
    }


}